package com.changgou.goods.handler;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice   //增强
public class BaseExceptionHandler{
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result handlerError(Exception e){
        //错误日志
        e.printStackTrace();
        //提示
        return new Result(false, StatusCode.ERROR,"服务器开小差了，请稍后再试");
    }

}
